package com.globalwave.common.appframe
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	
	import mx.core.FlexGlobals;
	import mx.core.UIComponent;
	import mx.managers.PopUpManager;
	
	public class ModuleWindow extends PopupWindow
	{
		private var moduleLoader:ModuleLoader ;
		private var url:String ;
		public var parentModule:UIComponent ;
		
		public function ModuleWindow(url:String, parentModule:UIComponent, width:Number=600, height:Number=500)
		{
			super();
			
			this.url = url ;
			this.parentModule = parentModule ;
			this.moduleLoader = new ModuleLoader(this) ; 
			this.addEventListener("initialize", thisOnInit) ;
			
			this.width = width ;
			this.height = height ;
			this.showCloseButton = true ;
			
			//var app:DisplayObject = DisplayObject(FlexGlobals.topLevelApplication) ;
			
			//PopUpManager.addPopUp(this, app, true);
			//PopUpManager.centerPopUp(this) ;
			this.addEventListener("close", thisOnClose) ;
		}
		
		private function thisOnInit(e:Event):void {	
			moduleLoader.load(url);
		}
		
		private function thisOnClose(e:Event):void {
		    PopUpManager.removePopUp(this) ;
		}
	}
}